package com.aaa.entity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

public class TUserDetails implements UserDetails {
    private Integer uid;
    private String name;
    private String sex;
    private String phone;
    private String idcard;
    private String site;
    private String remarks;
    private String entry;
    private String dimission;
    private String head;
    private String username;
    private String password;
    private String state;

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getEntry() {
        return entry;
    }

    public void setEntry(String entry) {
        this.entry = entry;
    }

    public String getDimission() {
        return dimission;
    }

    public void setDimission(String dimission) {
        this.dimission = dimission;
    }

    public String getHead() {
        return head;
    }

    public void setHead(String head) {
        this.head = head;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }


    private  Collection<? extends GrantedAuthority> authorities;//权限（角色 + 权限）


    @Override
    public String toString() {
        return "TUserDetails{" +
                "uid=" + uid +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", phone='" + phone + '\'' +
                ", idcard='" + idcard + '\'' +
                ", site='" + site + '\'' +
                ", remarks='" + remarks + '\'' +
                ", entry='" + entry + '\'' +
                ", dimission='" + dimission + '\'' +
                ", head='" + head + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", state='" + state + '\'' +
                '}';
    }

    public void setAuthorities(String... authorities) {
        List<GrantedAuthority> authorityList = AuthorityUtils.createAuthorityList(authorities);
        this.authorities=authorityList;
    }

    //获取权限
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }
    //获取密码
    public String getPassword() {
        return this.password;
    }
   //获取用户名
    public String getUsername() {
        return this.username;
    }
   //账户 是否过期 true 没有过期  false 过期
    public boolean isAccountNonExpired() {
        return true;
    }
    //账户是否锁定
    public boolean isAccountNonLocked() {
        return true;
    }
     //密码是否过期
    public boolean isCredentialsNonExpired() {
        return true;
    }
      //是否启用
    public boolean isEnabled() {
        return true;
    }
}
